import request from './ajax'

// 获取角色
export const getRoles = () => {
  return request({
    url: '/private/v1/roles',
    method: 'get'
  })
}
// 删除角色
export const removeRoleTag = (roleId, rightId) => {
  return request({
    url: `/private/v1/roles/${roleId}/rights/${rightId}`,
    method: 'delete'
  })
}
// 获取角色列表
export const getRight = () => {
  return request({
    url: '/private/v1/rights/tree',
    method: 'get'
  })
}
// 设置权限
export const setUserPower = (id, idstr) => {
  return request({
    url: `/private/v1/roles/${id}/rights`,
    method: 'post',
    data: idstr
  })
}

export const setRole = () => {
  return request({
    url: '/private/v1/roles',
    method: 'get'
  })
}
// 保存角色信息
export const saveRoleInfo = (id, rId) => {
  return request({
    url: `/private/v1/users/${id}/role`,
    method: 'put',
    data: rId
  })
}

// 添加角色
export const addRole = (data) => {
  return request({
    method: 'POST',
    url: '/private/v1/roles',
    data
  })
}

// 删除角色
export const deleteRole = (roleId) => {
  return request({
    method: 'DELETE',
    url: `/private/v1/roles/${roleId}`
  })
}
